﻿using UnityEngine;
using System.Collections;
using System;
using UnityEngine.UI;

public class EasySDKDemo : MonoBehaviour
{
    public Text log_Text;
    // Use this for initialization
    void Awake()
    {
        Application.logMessageReceived += LogCallback;
    }

    private void LogCallback(string condition, string stackTrace, LogType type)
    {
        log_Text.text += GetColorContent(condition, type)+ stackTrace+"\n";
    }

    private string GetColorContent(string condition, LogType type)
    {
        string text = "";
        if (type == LogType.Log)
        {
            text += "<color=green>" + condition + "</color>\n";
        }
        else if (type == LogType.Error || type == LogType.Exception)
        {
            text += "<color=red>" + condition + "</color>\n";
        }
        else
            text = condition;
        return text;
    }
    public EasySDKCallBackListener listener;
    public void Button_Init()
    {
        EasySDKManager.Init(listener);
    }

    public void Button_Login()
    {
        EasySDKManager.Login();
    }
    public void Button_Logout()
    {
        EasySDKManager.Logout();
    }
    public InputField goodID_InputField;
    public void Button_Pay()
    {
        OrderInfo orderInfo = new OrderInfo();
        orderInfo.goodsID = goodID_InputField.text;
        orderInfo.propType = OrderInfo.PropType.NORMAL;
        EasySDKManager.Pay(orderInfo);
    }

    public void OnButton_DataReport_Login()
    {
        EasySDKManager.DataReport_Login(SystemInfo.deviceUniqueIdentifier);
    }

    public void OnButton_DataReport_Logout()
    {
        EasySDKManager.DataReport_Logout();
    }
    public InputField eventID_InputField;
    public InputField eventLabel_InputField;
    public InputField eventMap_InputField;
    public void OnButton_DataReport_Event()
    {
        EasySDKManager.DataReport_Event(eventID_InputField.text, eventLabel_InputField.text, eventMap_InputField.text);
    }

    public void OnQuitGame()
    {
        EasySDKManager.QuitGame();
    }
}
